home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2007 December / PCWKCD1207B.iso / Windows marzen / Macro ToolsWorks 6.31 / tworks.exe / Samples / Add prefix and postfix text to each line in text file.mcr < prev    next >
Text File  |  2003-08-14  |  1KB  |  42 lines

  1. <#> 
  2. <#> This sample adds prefix and postfix text to each line in a selected text file
  3. <#> 
  4. <cmds>
  5.  
  6. <form_item>("f1","Input file:","EDIT_FILE","*.txt","vInputFile")
  7. <form_item>("f1","Output file:","EDIT_FILE","%_vFolder_Temp%\output.txt","vOutputFile")
  8. <form_item>("f1","Prefix:","EDIT",">>>","vPrefix")
  9. <form_item>("f1","Postfix:","EDIT","<<<","vPostfix")
  10. <form_show>("f1","Form","shell32.dll",0,,0)
  11. <if_str>("_vCanceled==1")<exitmacro><endif>
  12.  
  13. <data_load>("vbTemp_FileText","vInputFile","")
  14. <data_save>("","vOutputFile","")
  15. <if_str>("_vErr==NO")
  16.    <var_oper>(vbTemp_NumOfLines,"vbTemp_FileText",TEXT_GET_NUMOFLINES,"","", "0")
  17.    <begloop>(vbTemp_NumOfLines)
  18.  
  19.       <varset>("v100=EXPR(%_vLoopCounter%/100)","")
  20.       <if_num>("_vLoopCounter == EXPR(100*%v100%)")
  21.              <msgoff>
  22.              <msg>(32,32,"%_vLoopCounter% lines of %vbTemp_NumOfLines% processed.","Processing",0)
  23.       <endif>
  24.       
  25.       <var_oper>(vbTemp_LineText,"vbTemp_FileText",TEXT_GET_LINE,"_vLoopCounter","", "0")
  26.  
  27.       <var_oper>(vbTemp_LineText,"%vbTemp_LineText%",STR_INSERT,"0","%vPrefix%", "0")
  28.       <var_oper>(vbTemp_LineText,"%vbTemp_LineText%",STR_APPEND,"%vPostfix%%_vKeyReturn%","", "0")
  29.  
  30.       <data_save>("vbTemp_LineText","vOutputFile","A")
  31.  
  32.    <endloop>
  33.  
  34. <else>
  35.    <msg>(-100,-100,"_vError","File Error",1)
  36. <endif>
  37.  
  38. <msg>(-100,-100,"Do you want to open output file now?","Message",2)
  39. <if_str>("_vMsgButton==YES")
  40.    <fileopen>("%vOutputFile%",0)
  41. <endif>
  42.